Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser/swagger-client.js: Throw errors for null types #508

Merged
merged 1 commit into from
Jul 23, 2015

Conversation

wking
Copy link
Contributor

@wking wking commented Jun 25, 2015

Avoid too much recursion errors with properties like:

"species": {
  "type": "string",
  "enum": [
    null,
    "cat",
    "dog"
  ]
}

The JSON Schema spec says for enums:

Elements in the array MAY be of any type, including null.

But they aren't supported by Swagger 2.0, because null isn't one
of Swagger 2's types
. This commit gives a more obvious hint about
that. It would be nice to have clarification in the spec so we
could link to tidier docs than the GitHub issue too.

It would be nice if I could point to line numbers (or the chain of
keys?) to find the broken entry in the parsed spec, but it doesn't
seem like that information is available in resolveAllOf and I'm not
clear enough on the larger picture here to know where that would plug
in.

Anyway, this PR should help avoid futher confusion on this issue in
the 2.0 series.

Avoid 'too much recursion' errors with properties like:

  "species": {
    "type": "string",
    "enum": [
      null,
      "cat",
      "dog"
    ]
  }

The JSON Schema spec says for enums [1]:

> Elements in the array MAY be of any type, including null.

But they aren't supported by Swagger 2.0, because null isn't one of
Swagger 2's types [2,3].  This commit gives a more obvious hint about
that.  It would be nice to have clarification in the spec so we could
link to tidier docs than the GitHub issue too [2].

It would be nice if I could point to line numbers (or the chain of
keys?) to find the broken entry in the parsed spec, but it doesn't
seem like that information is available in resolveAllOf and I'm not
clear enough on the larger picture here to know where that would plug
in.

[1]: http://json-schema.org/latest/json-schema-validation.html#anchor77
[2]: OAI/OpenAPI-Specification#229 (comment)
[3]: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types
fehguy added a commit that referenced this pull request Jul 23, 2015
browser/swagger-client.js: Throw errors for null types
@fehguy fehguy merged commit 1daf5bf into swagger-api:develop_2.0 Jul 23, 2015
fehguy added a commit that referenced this pull request Jul 23, 2015
@fehguy
Copy link
Contributor

fehguy commented Jul 23, 2015

please note that I had to apply this:

658201b

Since your commit was in the compiled library and would be overwritten on next build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants